package com.example.interceptor.config;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Controller
public class MyConfig implements WebMvcConfigurer {
    @Autowired
    MyInterceptor myInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
       registry.addInterceptor(myInterceptor)
               .addPathPatterns("/**")//表示所有请求拦截
               .excludePathPatterns("/login","/article_img/**","/assets/**","/back/**","user/**");//表示对/login请求不拦截
        // /**表示对所有的请求都进行拦截，包括当前目录的文件和子目录的文件
        // /* 表示对
    }
}
